<?php
namespace Common\Controller;
use Base\Controller;


class PublicController extends Controller {
	//网站相关配置
	var $config=array();

	var $user_id;
	// 分页展示数
	protected $limit = 20;
	//缓存时间 s
	protected $cacheTime = 120;

	
	public function _initialize() {
		parent::_initialize();
		if(is_file('./site.inc.php')){
			$this->config = @include('./site.inc.php');
		} else {
			$common = '//站点配置信息';
			$this->config = M('SystemConfig')->getField('code,value');
			$content  = "<?php \n".$common."\nreturn ".var_export($this->config,true).";\n?>";
			file_put_contents('./site.inc.php',$content);					
		}
		if( !empty($_SESSION['user']) ) {
			$userEvent = new UserEvent();
			$this->user		=	unserialize(stripcslashes(isset($_SESSION['user']) ? $_SESSION['user'] : ''));
			$this->user_id	=	$this->user['user_id'];
		}
		$this->assign("user", $this->user);
		$this->assign("config",$this->config);
	}
}
